﻿using Learun.Util;
using SqlSugar;
using System;
using System.Collections.Generic;
namespace Learun.Application.TwoDevelopment.ZZDT_EC

{
    /// <summary>
    /// 版 本 PIT-ADMS V7.0.3 敏捷开发框架
    /// Copyright (c) 2013-2018 Hexagon PPM
    /// 创 建：YuXH
    /// 日 期：2022-06-21 15:32
    /// 描 述：开关实体
    /// </summary>
    [SugarTable(TableName = "ec_CircuitBreaker")]
    public class ec_CircuitBreakerEntity
    {
        #region 实体成员
        /// <summary>
        /// 分电箱的Id(不在Enginedata_rel中存储)
        /// </summary>
        /// <returns></returns> 
        public string PDBId { get; set; }
        /// <summary>
        /// 电缆，如果多个就逗号分隔
        /// </summary>
        /// <returns></returns> 
        public string CableID { get; set; }
        /// <summary>
        /// 顺序
        /// </summary>
        public int OrderId { get; set; }

        /// <summary>
        /// 开关的类型，输入(In)输出(Out)
        /// </summary>
        /// <returns></returns>
        public string CB_Type { get; set; } = "";

        ///// <summary>
        ///// ID
        ///// </summary>
        ///// <returns></returns>
        //[Column("ID")]
        //public string ID { get; set; }


        /// <summary>
        /// 脱扣线圈的Id
        /// </summary>
        /// <returns></returns>
        public string CoilId { get; set; } = "";
        /// <summary>
        /// 名字
        /// </summary>
        public string Name { get; set; } = "";
        /// <summary>
        /// 最大值（额定电流）
        /// </summary>
        public string Capacity_Max { get; set; } = "";
        /// <summary>
        /// 整定电流
        /// </summary>
        public string Capacity_Set { get; set; } = "";

        /// <summary>
        /// 实际电流
        /// </summary>
        public string Capacity_Act { get; set; } = "";
        /// <summary>
        /// 额定电压
        /// </summary>
        public string Rated_Voltage { get; set; } = "";
        /// <summary>
        /// 相数
        /// </summary>
        public int Phase { get; set; }
        /// <summary>
        /// GUFO里有
        /// </summary>
        public string Power_Opening { get; set; } = "";

        /// <summary>
        /// GUFO里有
        /// </summary>
        public string Power_Closing { get; set; } = "";

        /// <summary>
        /// GUFO里有
        /// </summary>
        public string Relay_Type { get; set; } = "";
        /// <summary>
        /// GUFO里有
        /// </summary>
        public double? Delay_Time { get; set; } = 0.0;
        /// <summary>
        /// 目前只有在本表里有，不会在<see cref="ec_enginedataEntity"/>表里出现对应的记录
        /// </summary>
        /// <returns></returns>
        [SugarColumn(IsPrimaryKey = true)]
        public string EngineerDataID { get; set; }
        /// <summary>
        /// 是否需要起动器
        /// </summary>
        /// <returns></returns>
        public int? NeedStarter { get; set; }
        /// <summary>
        /// 起动类型
        /// </summary>
        /// <returns></returns>
        public string StartType { get; set; }
        /// <summary>
        /// 顺序起动分组结果
        /// </summary>
        /// <returns></returns>
        public string SequentialStartGroup { get; set; }
        /// <summary>
        /// 是否带交流电流表
        /// </summary>
        /// <returns></returns>
        public int? ACAmmeter { get; set; }
        /// <summary>
        /// 起动方式
        /// </summary>
        /// <returns></returns>
        public string StartModel { get; set; }
        /// <summary>
        /// 可逆
        /// </summary>
        /// <returns></returns>
        public int? REV { get; set; }
        /// <summary>
        /// 是否自动起动
        /// </summary>
        /// <returns></returns>
        public int? AutoStart { get; set; }
        /// <summary>
        /// 是否带运行时间表
        /// </summary>
        /// <returns></returns>
        public int? RHM { get; set; }
        /// <summary>
        /// 欠压方式
        /// </summary>
        /// <returns></returns>
        public string UVMode { get; set; }
        /// <summary>
        /// 创建人
        /// </summary>
        /// <returns></returns>
        public string CreateUserID { get; set; }
        /// <summary>
        /// 创建时间
        /// </summary>
        /// <returns></returns>
        public DateTime? CreateTime { get; set; }
        /// <summary>
        /// 更新人
        /// </summary>
        /// <returns></returns>
        public string UpdateUserID { get; set; }
        /// <summary>
        /// 更新时间
        /// </summary>
        /// <returns></returns>
        public DateTime? UpdateTime { get; set; }
        #endregion

        #region 扩展操作
        /// <summary>
        /// 新增调用
        /// </summary>
        public void Create()
        {
            this.EngineerDataID = Guid.NewGuid().ToString();
            this.CreateTime = Time.MySqlTime;
            UserInfo userInfo = LoginUserInfo.Get();
            this.CreateUserID = userInfo.userId;


        }
        /// <summary>
        /// 编辑调用
        /// </summary>
        /// <param name="keyValue"></param>
        public void Modify(string keyValue)
        {
            this.EngineerDataID = keyValue;
            this.UpdateTime = Time.MySqlTime;
            UserInfo userInfo = LoginUserInfo.Get();
            this.UpdateUserID = userInfo.userId;
        }
        #endregion

        #region 扩展字段

        /// <summary>
        /// 分电箱的位号（表enginedata里）
        /// </summary>
        [SugarColumn(IsIgnore = true)]
        public string PDBName { get; set; }
        /// <summary>
        /// 分电箱的类型（表objecttype里）
        /// </summary>
        [SugarColumn(IsIgnore = true)]
        public string ObjectTypeName { get; set; }
        [SugarColumn(IsIgnore = true)]
        public Coil Coil { get; set; }

        /// <summary>
        /// 电缆，如果多个就逗号分隔
        /// </summary>
        /// <returns></returns>
        [SugarColumn(IsIgnore = true)]
        public string CableName { get; set; }

        /// <summary>
        /// 关联的电缆ID（可能有多个）
        /// </summary>
        [SugarColumn(IsIgnore = true)]
        public List<string> CableIDs { get; set; }
        /// <summary>
        /// 关联的电缆名字（实际上就一个）
        /// </summary>
        [SugarColumn(IsIgnore = true)]
        public List<string> CableTagNumbers { get; set; }
        /// <summary>
        /// 对面的设备信息（包括设备类型、设备位号、开关号等）
        /// </summary>
        [SugarColumn(IsIgnore = true)]
        public string RemoteDeviceId { get; set; }
        /// <summary>
        /// 对面的开关（不一定有）
        /// </summary>
        [SugarColumn(IsIgnore = true)]
        public ec_CircuitBreakerEntity RemoteCB { get; set; }
        [SugarColumn(IsIgnore = true)]
        public string RemoteDeviceName { get; set; }
        [SugarColumn(IsIgnore = true)]
        public string RemoteDeviceObjectType { get; set; }

        #endregion
    }
    /// <summary>
    /// 脱扣线圈
    /// </summary>
    public class Coil
    {
        public string Id { get; set; }
        public string Name { get; set; }
        /// <summary>
        /// ES功能
        /// </summary>
        public string Func_ES { get; set; }
        /// <summary>
        /// PT功能
        /// </summary>
        public string Func_PT { get; set; }
    }
}

